package com.gxa.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.common.R;
import com.gxa.common.vo.AbnormalWarning;
import com.gxa.entity.DistrictSysNotice;
import com.gxa.mapper.AbnormalWarningMapper;
import com.gxa.service.AbnormalWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AbnormalWarningServiceImpl implements AbnormalWarningService {

    @Autowired
    private AbnormalWarningMapper abnormalWarningMapper;

    //查询所有异常预警
    @Override
    public R findAll(Integer currentPage, Integer pageSize) {
        R r = new R();
        try{
            PageHelper.startPage(currentPage,pageSize);
            List<AbnormalWarning> abnormalWarnings = abnormalWarningMapper.findAll();
            PageInfo<AbnormalWarning> pageInfo = new PageInfo<AbnormalWarning>(abnormalWarnings);
            r.setCode(200);
            r.setMsg("success");
            r.setData(pageInfo);
        }catch (Exception e){
            e.printStackTrace();
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;
    }

    //条件查询
    @Override
    public R selectByName(Integer currentPage, Integer pageSize, String name, String sex, String idCard, String phoneNum, String status, Date registrationDate) {
        R r = new R();
        try{
            PageHelper.startPage(currentPage,pageSize);
            List<AbnormalWarning> abnormalWarnings = abnormalWarningMapper.selectByName(name,sex,idCard,phoneNum,status,registrationDate);
            PageInfo<AbnormalWarning> pageInfo = new PageInfo<AbnormalWarning>(abnormalWarnings);
            r.setCode(200);
            r.setMsg("success");
            r.setData(pageInfo);
        }catch (Exception e){
            e.printStackTrace();
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;
    }

    //转为确诊
    @Override
    public R turnDiagnosis(int id) {
        return null;
    }
}
